# coding=utf-8
__author__ = 'Administrator'

import configparser
import os


class IntFileReader:
    cf = configparser.ConfigParser()

    def __init__(self, inifile=None, encoding=None):

        if inifile is None:
            raise "ini config file must init!"

        self.inifile = inifile
        self.encoding = encoding
        self.cf.read(self._get_ini_file())

    def _get_ini_file(self):
        # path = os.path.join(os.path.abspath(".."), "configuration")
        path = os.path.join(os.getcwd())
        print("path==",path)
        return os.path.join(path, self.inifile)


if __name__ == "__main__":
    ifr = IntFileReader("config.ini")
    print("all section:", ifr.cf.sections())
    # print("", ifr.cf.get("db", "host"))
